<template>
    <a-card :bordered="false">
        <div class="table-operator">
             <a-button v-if="selectedRowKeys.length > 0" style="margin-left: 8px" @click="batchDel">
                批量删除
            </a-button>
        
        </div>
        <LTable
            ref="loginLogList"
            size="middle"
            rowKey="keyId"
            :formAttributes="formAttributes"
            :columns="columns"
            axiosUrl="/SysLoginLogController/page"
            :showPagination="true"
            :showQueryForm="true"
            :initOrder="initOrder"
            :rowSelection="{onChange:onSelectChange}"
        >
        
    </LTable>
    </a-card>
</template>

<script>
import LTable from '@/components/lt/LTable'
import {SysMixin} from '@/mixins/SysMixin'
import defaultSettings from '@/config/defaultSettings'
import request from '@/utils/request'
import { Modal } from 'ant-design-vue'
export default {
    name:'loginLogList',
    components:{
       LTable
    },
    mixins:[SysMixin],
    data(){
        return{
            Modal,
            defaultSettings,
            formAttributes:[
                
                {field:'loginEmpNo',label:'登录人工号',component:'input',condition:'like'},
                {field:'loginAccountNo',label:'登录人账号',component:'input',condition:'like'},
                {field:'loginEmpName',label:'登录人姓名',component:'input',condition:'like'},
                {field:'loginTime',label:'登录时间',component:'time',condition:'between'},
            ],
            initOrder:[{field:'loginTime',val:'desc'}],
            columns:[
                {
                    title: '序号',
                    dataIndex: '',
                    key:'rowIndex',
                    width:60,
                    align:"center",
                    customRender:function (t,r,index) {
                      return parseInt(index)+1;
                    }
                },
                
                {
                    title: '登录人姓名',
                    dataIndex: 'loginEmpName'
                },
                {
                    title: '登录人账号',
                    dataIndex: 'loginAccountNo'
                },
                 {
                    title: '登录人工号',
                    dataIndex: 'loginEmpNo'
                },
                {
                    title: '登录IP',
                    dataIndex: 'loginIp'
                },
              
                {
                    title: '登录时间',
                    dataIndex: 'loginTime'
                },
               
            ],
            selectedRowKeys:[],
            
        }
    },
    created(){
       
    },
    methods:{
        onSelectChange (selectedRowKeys, selectedRows) {
            this.selectedRowKeys = selectedRowKeys
        },
        batchDel(){
            if(this.selectedRowKeys.length>0){
                var that = this;
                Modal.confirm({
                    title: "系统提醒",
                    content: "确定删除吗?",
                    onOk: () => {
                        request.get('/SysLoginLogController/batchDel',{params:{keyIds:this.selectedRowKeys.join(",")}}).then((res)=>{
                            if (res.success) {
                                this.$message.success(res.message)
                                this.refresh('loginLogList')
                                this.selectedRowKeys=[]
                            } else {
                                this.$message.warning(res.message);
                            }
                        })
                    },
                    onCancel () {}
                })
                
            }
        }
        
    }
}
</script>